from web.template import CompiledTemplate, ForLoop


def add():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__ (form):
        yield '', join_('\n')
        def get_myscripts():
            yield '', join_('<!-- tinyMCE -->\n')
            yield '', join_('<script language="javascript" type="text/javascript" src="/jscripts/tiny_mce/tiny_mce.js"></script>\n')
            yield '', join_('<script language="javascript" type="text/javascript">\n')
            yield '', join_('tinyMCE.init({\n')
            yield '', join_('mode : "textareas",\n')
            yield '', join_('theme : "advanced",\n')
            yield '', join_('theme_advanced_toolbar_location : "top",\n')
            yield '', join_('theme_advanced_toolbar_align : "left",\n')
            yield '', join_('theme_advanced_toolbar_statusbar_location : "bottom",\n')
            yield '', join_('theme_advanced_resizing : true,\n')
            yield '', join_('});\n')
            yield '', join_('</script>\n')
            yield '', join_('<!-- /tinyMCE -->\n')
        yield '', join_('\n')
        yield 'title', join_('myscripts')
        yield 'scripts', join_(escape_(get_myscripts(), True))
        yield '', join_('\n')
        yield '', join_('<div id="content" class="narrowcolumn">\n')
        yield '', join_('    <p> \xe6\x81\xad\xe8\xbf\x8e\xe5\xa4\xa7\xe4\xbe\xa0 (', escape_(session.username, True), ') | <a href="/logout">\xe5\x87\xba\xe9\x97\xa8\xe8\xaf\xb7\xe8\xb5\xb0\xe8\xbf\x99\xe5\x84\xbf</a></p>\n')
        yield '', join_('    <form action="/add" method="post">\n')
        if not form.valid:
            yield '', join_('      ', '<p>\xe5\xbe\x88\xe6\x8a\xb1\xe6\xad\x89\xef\xbc\x8c\xe6\x82\xa8\xe7\x9a\x84\xe4\xbd\x9c\xe5\x93\x81\xe5\x8f\xaf\xe8\x83\xbd\xe4\xb8\x8d\xe7\xac\xa6\xe5\x90\x88\xe8\xa7\x84\xe8\x8c\x83\xef\xbc\x8c\xe8\xaf\xb7\xe6\xa3\x80\xe6\x9f\xa5</p>\n')
        yield '', join_('      ', escape_(form.render(), False), '\n')
        yield '', join_('    <input type="submit" name="post_submit" value="\xe6\x94\xb6\xe5\x8a\x9f" />\n')
        yield '', join_('    </form>\n')
        yield '', join_('</div>\n')
    return __template__

add = CompiledTemplate(add(), 'templates\\add.html')


def archive():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__ (articles):
        yield 'title', join_('archive page')
        yield '', join_('\n')
        yield '', join_('<div id="content" class="narrowcolumn">\n')
        yield '', join_('\n')
        yield '', join_('<ul>\n')
        for article in loop.setup(articles):
            yield '', join_('<li><a href="/view/', escape_(article.id, True), '">', escape_(article.title, True), '</a>\n')
        yield '', join_('</ul>\n')
        yield '', join_('\n')
        yield '', join_('</div>\n')
    return __template__

archive = CompiledTemplate(archive(), 'templates\\archive.html')


def edit():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__ (edit_form, id):
        yield 'title', join_('edit blog')
        yield '', join_('\n')
        def get_myscripts():
            yield '', join_('<!-- tinyMCE -->\n')
            yield '', join_('<script language="javascript" type="text/javascript" src="/jscripts/tiny_mce/tiny_mce.js"></script>\n')
            yield '', join_('<script language="javascript" type="text/javascript">\n')
            yield '', join_('tinyMCE.init({\n')
            yield '', join_('mode : "textareas",\n')
            yield '', join_('theme : "advanced",\n')
            yield '', join_('theme_advanced_toolbar_location : "top",\n')
            yield '', join_('theme_advanced_toolbar_align : "left",\n')
            yield '', join_('theme_advanced_toolbar_statusbar_location : "bottom",\n')
            yield '', join_('theme_advanced_resizing : true,\n')
            yield '', join_('});\n')
            yield '', join_('</script>\n')
            yield '', join_('<!-- /tinyMCE -->\n')
        yield '', join_('\n')
        yield 'title', join_('edit blog')
        yield 'scripts', join_(escape_(get_myscripts(), True))
        yield '', join_('\n')
        yield '', join_('<div id="content" class="narrowcolumn">\n')
        yield '', join_('\n')
        yield '', join_('<form action="/edit" method="post">\n')
        if not edit_form.valid:
            yield '', join_('<p>\xe5\xaf\xb9\xe4\xb8\x8d\xe8\xb5\xb7\xef\xbc\x8c\xe6\x82\xa8\xe8\xbe\x93\xe5\x85\xa5\xe7\x9a\x84\xe4\xb8\x9c\xe8\xa5\xbf\xe5\x8f\xaf\xe8\x83\xbd\xe4\xb8\x8d\xe5\xa4\xa7\xe5\xaf\xb9\xe5\x8a\xb2\xef\xbc\x8c\xe8\xa6\x81\xe4\xb8\x8d\xe5\x86\x8d\xe7\x9e\x85\xe7\x9e\x85</p>\n')
        yield '', join_(escape_(edit_form.render(), False), '\n')
        yield '', join_('<input type="submit" name="post_submit" value="\xe5\x86\x99\xe5\xae\x8c\xe5\x95\xa6" />\n')
        yield '', join_('</form>\n')
        yield '', join_('</div>\n')
    return __template__

edit = CompiledTemplate(edit(), 'templates\\edit.html')


def index():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__ (articles, tag_list, recent_posts, month_list, curr_page, page_count, cate_list, blog_rolls):
        yield 'title', join_("Michael's Blog")
        yield '', join_('\n')
        yield '', join_('<div id="content" class="narrowcolumn">\n')
        yield '', join_('\n')
        for article in loop.setup(articles):
            yield '', join_('<div class="post">\n')
            yield '', join_('<h2><a title=', escape_(article.title, True), ' href="../view/', escape_(article.id, True), '">', escape_(article.title, True), '</a></h2>\n')
            yield '', join_('<small>', escape_(article.published_when.strftime("%Y/%m/%d"), True), '</small>\n')
            yield '', join_('<div class="entry">\n')
            yield '', join_(escape_(article.body, True), '\n')
            yield '', join_('</div>\n')
            yield '', join_('<p class="postmetadata">Tags: \n')
            for cate in loop.setup(article.tags):
                yield '', join_('<a href="../tag/', escape_(cate, True), '">', escape_(cate, True), '</a> \n')
            yield '', join_('| <a href="../view/', escape_(article.id, True), '">', escape_(article.total_comment(), True), ' Comment</a>\n')
            yield '', join_('</div>\n')
        yield '', join_('\n')
        yield '', join_('<div class="navigation">\n')
        if curr_page <= 1:
            yield '', join_('<div class="alignleft">&nbsp;</div>\n')
        else:
            yield '', join_('<div class="alignleft">&laquo;<a href="../page/', escape_((curr_page-1), True), '">newer_posts</a></div>\n')
        if curr_page >= page_count:
            yield '', join_('<div class="alignright">&nbsp;</div>\n')
        else:
            yield '', join_('<div class="alignright">&raquo;<a href="../page/', escape_((curr_page+1), True), '">older posts</a></div>\n')
        yield '', join_('</div>\n')
        yield '', join_('\n')
        yield '', join_('</div>\n')
        yield '', join_('\n')
        yield '', join_('<div id="sidebar">\n')
        yield '', join_('<ul>\n')
        yield '', join_('            <li>\n')
        yield '', join_('              <form method="get" id="searchform" action="/search">\n')
        yield '', join_('<label class="hidden" for="s">Search for:</label>\n')
        yield '', join_('<div><input type="text" value="" name="s" id="s" />\n')
        yield '', join_('<input type="submit" id="searchsubmit" value="Search" />\n')
        yield '', join_('</div>\n')
        yield '', join_('</form>\n')
        yield '', join_('      </li>\n')
        yield '', join_('\n')
        yield '', join_('<li><h2>Tags</h2>\n')
        if tag_list:
            yield '', join_('<div id="tag-cloud">\n')
            for tag_count in loop.setup(tag_list):
                yield '', join_('<a class="', escape_(tag_count.css_class, True), '" href="../tag/', escape_(tag_count.tag, True), '">', escape_((tag_count.tag), True), '(', escape_(tag_count.count, True), ')</a>\n')
                if not loop.last:
                    yield '', join_(',\n')
            yield '', join_('</div>\n')
        yield '', join_(' \n')
        yield '', join_('</li>\n')
        yield '', join_('\n')
        yield '', join_('<li class="categories"><h2>Categories</h2>\n')
        if cate_list:
            yield '', join_('<ul>\n')
            for cate in loop.setup(cate_list):
                yield '', join_('<li class="cat_item"><a href="../cat/', escape_(cate, True), '">', escape_(cate, True), '</a></li>\n')
            yield '', join_('</ul>\n')
        yield '', join_('</li>\n')
        yield '', join_('\n')
        yield '', join_('<li id="linkcat-2" class="linkcat"><h2>Blogroll</h2>\n')
        if blog_rolls:
            yield '', join_('<ul class="xoxo blogroll">\n')
            for roll in loop.setup(blog_rolls):
                yield '', join_('<li><a href="http://solidot.org">', escape_(roll, True), '</a></li>\n')
            yield '', join_('</ul>\n')
        yield '', join_('</li>\n')
        yield '', join_('\n')
        yield '', join_('<li><h2>Archive</h2>\n')
        if month_list:
            yield '', join_('<ul>\n')
            for month in loop.setup(month_list):
                yield '', join_('  ', '<li><a href="../date/', escape_(month.date.strftime('%Y-%m'), True), '">', escape_(month.date.strftime('%Y-%m'), True), '</a> (', escape_(month.count, True), ')</li>\n')
            yield '', join_('</ul>\n')
        yield '', join_('</li>\n')
        yield '', join_('\n')
        yield '', join_('<li><h2>Meta</h2>\n')
        yield '', join_('<ul>\n')
        if session.login is False:
            yield '', join_('<LI><A HREF="/login">login</A></LI>\n')
        else:
            yield '', join_('<LI><A HREF="/add">write blog</A></LI>\n')
            yield '', join_('<LI><A HREF="/manage">manage blog</A></LI>\n')
            yield '', join_('<LI><A HREF="/logout">logout</A></LI>\n')
        yield '', join_('</ul>\n')
        yield '', join_('</li>\n')
        yield '', join_('\n')
        yield '', join_('</ul>\n')
        yield '', join_('\n')
        yield '', join_('</div>\n')
        yield '', join_('<hr />\n')
    return __template__

index = CompiledTemplate(index(), 'templates\\index.html')


def layout():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__ (content):
        yield '', join_('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n')
        yield '', join_('    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n')
        yield '', join_('<HTML dir=ltr lang=zh-CN xmlns="http://www.w3.org/1999/xhtml">\n')
        yield '', join_('<HEAD>\n')
        yield '', join_('<meta name="baidu_union_verify" content="ee2cc5de61ff88f4a4d46f6849fcaca0">\n')
        yield '', join_('<TITLE>', escape_(content.title, True), '</TITLE>\n')
        yield '', join_('<meta http-equiv="Content-Type" content="text/html"; charset="UTF-8" />\n')
        yield '', join_('<LINK rel=stylesheet type=text/css href="/static/style.css">\n')
        yield '', join_('<LINK rel=stylesheet type=text/css href="/static/tag_style.css">\n')
        yield '', join_('<style type="text/css" media="screen">\n')
        yield '', join_('  #page { background: url("/static/images/kubrickbgwide.jpg") repeat-y top; border: none; }\n')
        yield '', join_('</style>\n')
        if "scripts" in content:
            yield '', join_('    ', escape_(content.scripts, True), '\n')
        yield '', join_('</HEAD>\n')
        yield '', join_('\n')
        yield '', join_('<body>\n')
        yield '', join_('  <div id="page">\n')
        yield '', join_('    \n')
        yield '', join_('    <div id="header">\n')
        yield '', join_('      <div id="headerimg">\n')
        yield '', join_('      <h1><a href="/">Thinking in Blog</a></h1>\n')
        yield '', join_('      <div class="description">art of life</div>\n')
        yield '', join_('      </div>\n')
        yield '', join_('    </div>\n')
        yield '', join_('    <hr />\n')
        yield '', join_('\n')
        yield '', join_('        ', escape_(content, False), '\n')
        yield '', join_('\n')
        yield '', join_('        <div id="footer">\n')
        yield '', join_('          <p>\n')
        yield '', join_('            Theme Copyright &copy;2009 <a href="http://wp-themes.com">wp-themes.com</a> &middot; Powered by <a href="http://webpy.org">web.py</a> and <a href="http://code.google.com/appengine"> google app engine</a> <br/>&copy; 2008,2009 <a href="mailto:starstarstarpku@gmail.com">MichaelXu</a>\n')
        yield '', join_('            <a title="Go to top" class="top" href="#top">Go to top &uarr;</a>\n')
        yield '', join_('            </p>\n')
        yield '', join_('        </div>\n')
        yield '', join_('  </div>\n')
        yield '', join_('</body>\n')
        yield '', join_('</html>\n')
    return __template__

layout = CompiledTemplate(layout(), 'templates\\layout.html')


def login():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__ (user, form):
        yield 'title', join_('login')
        yield '', join_('\n')
        yield '', join_('<div id="content" class="narrowcolumn">\n')
        if session.login == False:
            yield '', join_('<p>\xe6\x82\xa8\xe5\xb0\x9a\xe6\x9c\xaa\xe7\x99\xbb\xe9\x99\x86\xe3\x80\x82\xe8\xaf\xb7\xe5\xa1\xab\xe5\xa5\xbd\xe4\xb8\x8b\xe9\x9d\xa2\xe7\x9a\x84\xe7\x99\xbb\xe9\x99\x86\xe4\xbf\xa1\xe6\x81\xaf\xef\xbc\x8c\xe7\x84\xb6\xe5\x90\x8e\xe7\x8c\x9b\xe5\x87\xbb<strong>\xe7\x99\xbb\xe9\x99\x86</strong>\xe6\x8c\x89\xe9\x92\xae</p>\n')
            yield '', join_('<p>\n')
            yield '', join_('<form action="/login" method="post">\n')
            yield '', join_(escape_(form.render(), False), '\n')
            yield '', join_('<input type="submit" name="login" value="\xe7\x99\xbb\xe9\x99\x86" />\n')
            yield '', join_('</form>\n')
            yield '', join_('</p>\n')
        else:
            yield '', join_('<p>\xe6\x81\xad\xe8\xbf\x8e\xe6\x95\x99\xe4\xb8\xbb ', escape_(user, True), '\xef\xbc\x81</p>\n')
        yield '', join_('  </div>\n')
    return __template__

login = CompiledTemplate(login(), 'templates\\login.html')


def logout():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__():
        yield '', join_('<html>\n')
        yield '', join_('<head>\n')
        yield '', join_('<title>blog</title>\n')
        yield '', join_('<link rel="stylesheet" type="text/css" href="styles.css" media="screen"/>\n')
        yield '', join_('</head>\n')
        yield '', join_('<body>\n')
        yield '', join_('<p>You have been logged out</p>\n')
        yield '', join_('<p><a href="/add">Continue</a><p>\n')
        yield '', join_('</body>\n')
        yield '', join_('</html>\n')
        yield '', join_('\n')
    return __template__

logout = CompiledTemplate(logout(), 'templates\\logout.html')


def manage():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__ (articles):
        yield 'title', join_('manage')
        yield '', join_('\n')
        yield '', join_('<script type="text/javascript">\n')
        yield '', join_('\n')
        yield '', join_('function clr()\n')
        yield '', join_('{\n')
        yield '', join_('    if (confirm("\xe5\x88\xa0\xe4\xba\x86\xe5\xb0\xb1\xe4\xb8\x80\xe6\x97\xa0\xe6\x89\x80\xe6\x9c\x89\xe5\x95\xa6\xef\xbc\x81"))\n')
        yield '', join_('    {\n')
        yield '', join_('        return "/clear";\n')
        yield '', join_('    }\n')
        yield '', join_('    return "/manage";\n')
        yield '', join_('}\n')
        yield '', join_('\n')
        yield '', join_('function del(id)\n')
        yield '', join_('{\n')
        yield '', join_('    if (confirm("\xe7\x82\xb9\xe7\xa1\xae\xe5\xae\x9a\xe5\x88\xa0\xe6\x8e\x89\xef\xbc\x8c\xe6\x88\x96\xe8\x80\x85\xe7\x82\xb9\xe5\x8f\x96\xe6\xb6\x88\xe4\xbf\x9d\xe7\x95\x99\xef\xbc\x9b\xe4\xbd\xa0\xe6\x98\xaf\xe7\x82\xb9\xe7\xa1\xae\xe5\xae\x9a\xe8\xbf\x98\xe6\x98\xaf\xe7\x82\xb9\xe5\x8f\x96\xe6\xb6\x88\xe5\x85\xa8\xe5\x8f\x96\xe5\x86\xb3\xe4\xba\x8e\xe4\xbd\xa0\xe8\x87\xaa\xe5\xb7\xb1\xe6\x88\x91\xe4\xb8\x8d\xe5\x8f\xaf\xe8\x83\xbd\xe5\xb8\xae\xe4\xbd\xa0\xe5\x81\x9a\xe5\x86\xb3\xe5\xae\x9a\xe4\xbd\xa0\xe7\x9c\x9f\xe7\x9a\x84\xe8\xa6\x81\xe7\xa1\xae\xe5\xae\x9a\xe5\x90\x97\xe4\xbd\xa0\xe7\x9c\x9f\xe7\x9a\x84\xe6\x83\xb3\xe5\xa5\xbd\xe4\xba\x86\xe5\x90\x97"))\n')
        yield '', join_('    {\n')
        yield '', join_('        return "/delete/"+id;\n')
        yield '', join_('    }\n')
        yield '', join_('    return "/manage";\n')
        yield '', join_('}\n')
        yield '', join_('</script>\n')
        yield '', join_('\n')
        yield '', join_('<div id="content" class="narrowcolumn">\n')
        yield '', join_('\n')
        yield '', join_('<a href="/clear" onClick="this.href=clr()">\xe7\x8e\x89\xe7\x9f\xb3\xe4\xbf\xb1\xe7\x84\x9a</a>\n')
        yield '', join_('<ul>\n')
        for article in loop.setup(articles):
            yield '', join_('<li class="admin-published">\n')
            yield '', join_(escape_(article.published_when.strftime("%H:%M:%S %m-%d-%Y"), True), ' &nbsp;\n')
            yield '', join_(escape_(article.title, True), '\n')
            yield '', join_('<a href="/edit/', escape_(article.id, True), '">\xe5\x86\x8d\xe6\x94\xb9\xe6\x94\xb9\xe5\x90\xa7</a>\n')
            yield '', join_('<a href="/delete/', escape_(article.id, True), '" onClick="this.href=del(', escape_(article.id, True), ')">\xe7\x9c\x8b\xe7\x9d\x80\xe4\xb8\x8d\xe7\x88\xbd\xef\xbc\x9f\xe7\x82\xb9\xe5\x87\xbb\xe6\x88\x91</a>\n')
        yield '', join_('</ul>\n')
        yield '', join_('</div>\n')
    return __template__

manage = CompiledTemplate(manage(), 'templates\\manage.html')


def month():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__ (articles):
        yield 'title', join_('month post')
        yield '', join_('\n')
        yield '', join_('<div id="content" class="narrowcolumn">\n')
        yield '', join_('\n')
        yield '', join_('<ul>\n')
        for article in loop.setup(articles):
            yield '', join_('<li><a href="/view/', escape_(article.id, True), '">', escape_(article.title, True), '</a>\n')
        yield '', join_('</ul>\n')
        yield '', join_('\n')
        yield '', join_('</div>\n')
    return __template__

month = CompiledTemplate(month(), 'templates\\month.html')


def notfound():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__():
        yield '', join_('Sorry! 4OOOOOOOOOOOOO4\n')
        yield '', join_('\n')
        yield '', join_('Try another url!\n')
    return __template__

notfound = CompiledTemplate(notfound(), 'templates\\notfound.html')


def tag():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__ (articles):
        yield 'title', join_('tag post')
        yield '', join_('\n')
        yield '', join_('<ul>\n')
        for article in loop.setup(articles):
            yield '', join_('<li><a href="/view/', escape_(article.id, True), '">', escape_(article.title, True), '</a>\n')
        yield '', join_('</ul>\n')
        yield '', join_('\n')
    return __template__

tag = CompiledTemplate(tag(), 'templates\\tag.html')


def view():
    loop = ForLoop()
    _dummy  = CompiledTemplate(lambda: None, "dummy")
    join_ = _dummy._join
    escape_ = _dummy._escape

    def __template__ (article, comment, prev, next):
        yield '', join_('\n')
        def ff_linebreak():
            yield '', join_('<script type="text/javascript">\n')
            yield '', join_('function toBreakWord(intLen, id){\n')
            yield '', join_('var obj=document.getElementById(id);\n')
            yield '', join_('var strContent=obj.innerHTML;\n')
            yield '', join_('var strTemp="";\n')
            yield '', join_('while(strContent.length>intLen){\n')
            yield '', join_('strTemp+=strContent.substr(0,intLen)+"<br>";\n')
            yield '', join_('strContent=strContent.substr(intLen,strContent.length);\n')
            yield '', join_('}\n')
            yield '', join_('strTemp+= strContent;\n')
            yield '', join_('obj.innerHTML=strTemp;\n')
            yield '', join_('}\n')
            yield '', join_('</script> \n')
            yield '', join_('\n')
        yield 'title', join_('view blog')
        yield 'scripts', join_(escape_(ff_linebreak(), True))
        yield '', join_('\n')
        yield '', join_('<div id="content" class="widecolumn">\n')
        yield '', join_('\n')
        yield '', join_('<div class="navigation">\n')
        yield '', join_('<div class="alignleft">&laquo; \n')
        if prev == None:
            yield '', join_('\xe6\xb2\xa1\xe6\x9c\x89\xe4\xba\x86\n')
        else:
            yield '', join_('<a href="../view/', escape_(prev.id, True), '">', escape_(prev.title, True), '</a>\n')
        yield '', join_('</div>\n')
        yield '', join_('<div class="alignright">&raquo;\n')
        if next == None:
            yield '', join_('\xe6\xb2\xa1\xe6\x9c\x89\xe4\xba\x86\n')
        else:
            yield '', join_('<a href="../view/', escape_(next.id, True), '">', escape_(next.title, True), '</a>\n')
        yield '', join_('</div>\n')
        yield '', join_('</div>\n')
        yield '', join_('\n')
        yield '', join_('<div class="post">\n')
        if article[0]:
            yield '', join_('<h2>', escape_(article[0].title, True), '</h2>\n')
            yield '', join_('<i><span class="timestamp">posted at ', escape_(article[0].published_when.strftime("%H:%M:%S %m-%d-%Y"), True), '</span></i>\n')
            yield '', join_('<div class="entry"> \n')
            yield '', join_('  ', escape_(article[0].body, True), '\n')
            yield '', join_('</div>\n')
            yield '', join_('<script type="javascript">toBreakWord(60, "wrap");</script>\n')
            yield '', join_('<p>\n')
            yield '', join_('  <a href="../edit/', escape_(article[0].id, True), '">edit</a> |\n')
            yield '', join_('    <a href="./', escape_(article[0].id, True), '">view</a>\n')
            yield '', join_('</p>\n')
        yield '', join_(' \n')
        yield '', join_('<h3 id="comments">Responses to &#8220;', escape_(article[0].title, True), '&#8221;</h3>\n')
        yield '', join_('<ol class="commentlist">\n')
        for row in loop.setup(comment):
            yield '', join_('<li class="alt">\n')
            yield '', join_(escape_(row.author, True), ' Says:\n')
            yield '', join_('<br />\n')
            yield '', join_('<small class="commentmetadata">', escape_(row.date.strftime("%H:%M:%S %m-%d-%Y"), True), '</small>\n')
            yield '', join_('<p>', escape_(row.content, True), '</p>\n')
            yield '', join_('</li>\n')
        yield '', join_('</ol>\n')
        yield '', join_('\n')
        yield '', join_('<form action="/comment" method="post">\n')
        yield '', join_('<label for="post_username">name</label><br />\n')
        yield '', join_('<input id="post_username" type="text" name="post_username" class="textbox"/><br />\n')
        yield '', join_('<label for="post_body">say something!</label><br />\n')
        yield '', join_('<textarea id="post_body" name="post_body" cols="60" rows="8" class="textbox"></textarea><br />\n')
        yield '', join_('<input type="hidden" name="post_id" value="', escape_(article[0].id, True), '" />\n')
        yield '', join_('<input type="submit" name="post_submit" value="GO" />\n')
        yield '', join_('</form>\n')
        yield '', join_('\n')
        yield '', join_('</div>\n')
        yield '', join_('</div>\n')
    return __template__

view = CompiledTemplate(view(), 'templates\\view.html')

